/// **************************************************************************************************
/// "Copyright (c) 2007 Sai Panyam, Inc.  All rights reserved."
/// **************************************************************************************************
/// Component Name   :	Util, Member of System72.NTextile 
/// Description      :	Util description
/// Author           :	Sai Panyam
/// Creation Date    :	November 09 2007
/// Modified Date    :              
/// Modified By      :
/// **************************************************************************************************
using System;
using System.Web.UI;

namespace System72.NTextile
{
    public static class Util
    {
        #region Private Variables

        private static readonly string m_tagLeft = HtmlTextWriter.TagLeftChar.ToString();//Prints <
        private static readonly string m_tagRight = HtmlTextWriter.TagRightChar.ToString();//Prints >
        private static readonly string m_endTagLeft = HtmlTextWriter.EndTagLeftChars;//Prints </
        private static readonly string m_doubleQuote = HtmlTextWriter.DoubleQuoteChar.ToString();//Prints " 
        private static readonly string m_equals = HtmlTextWriter.EqualsChar.ToString();//Prints =
        private static readonly string m_equalsDoubleQuote = HtmlTextWriter.EqualsDoubleQuoteString;//Prints ="
        private static readonly string m_selfClosing = HtmlTextWriter.SelfClosingChars;//Prints (space)/ 
        private static readonly string m_selfClosingTagEnd = HtmlTextWriter.SelfClosingTagEnd;//Prints /> 
        private static readonly string m_semicolon = HtmlTextWriter.SemicolonChar.ToString();//Prints ; 
        private static readonly string m_singleQuote = HtmlTextWriter.SingleQuoteChar.ToString();//Prints ' 
        private static readonly string m_slash = HtmlTextWriter.SlashChar.ToString();//Prints / 
        private static readonly string m_space = HtmlTextWriter.SpaceChar.ToString();//Prints (space)
        private static readonly string m_styleEquals = HtmlTextWriter.StyleEqualsChar.ToString();//Prints :
        
        #endregion

        #region Public Properties

        /// <summary>
        /// Represents the opening angle bracket (&lt;) of a markup tag
        /// </summary>
        public static string TagLeft
        {
            get
            {
                return m_tagLeft;
            }
        }
        /// <summary>
        /// Represents the opening angle bracket (&gt;) of a markup tag
        /// </summary>
        public static string TagRight
        {
            get
            {
                return m_tagRight;
            }
        }
        /// <summary>
        /// Represents the left angle bracket and slash mark (&lt;/) of the closing tag of a markup element.
        /// </summary>
        public static string EndTagLeft
        {
            get
            {
                return m_endTagLeft;
            }
        }
        /// <summary>
        /// Represents the quotation  marks (") character
        /// </summary>
        public static string DoubleQuote
        {
            get
            {
                return m_doubleQuote;
            }
        }
        /// <summary>
        /// Represents the equals sign (=)
        /// </summary>
        public static string Equal
        {
            get
            {
                return m_equals;
            }
        }
        /// <summary>
        /// Represents an equal sign (=) and a double quotation mark (") together in a string (=").
        /// </summary>
        public static string EqualsDoubleQuote
        {
            get
            {
                return m_equalsDoubleQuote;
            }
        }
        /// <summary>
        /// Represents a space and the self-closing slash mark ( /) of a markup tag.
        /// </summary>
        public static string SelfClosing
        {
            get
            {
                return m_selfClosing;
            }
        }
        /// <summary>
        /// Represents the closing slash mark and right angle bracket (/>) of a self-closing markup element.
        /// </summary>
        public static string SelfClosingTagEnd
        {
            get
            {
                return m_selfClosingTagEnd;
            }
        }
        /// <summary>
        /// Represents the semicolon (;).
        /// </summary>
        public static string Semicolon
        {
            get
            {
                return m_semicolon;
            }
        }
        /// <summary>
        /// Represents the aphostrophe (').
        /// </summary>
        public static string SingleQuote
        {
            get
            {
                return m_singleQuote;
            }
        }
        /// <summary>
        /// Represents the slash character (/).
        /// </summary>
        public static string Slash
        {
            get
            {
                return m_slash;
            }
        }
        /// <summary>
        /// Represents a space ( ) character.
        /// </summary>
        public static string Space
        {
            get
            {
                return m_space;
            }
        }
        /// <summary>
        /// Represents the style equals (:) character used to set style attributes equal to values.
        /// </summary>
        public static string StyleEquals
        {
            get
            {
                return m_styleEquals;
            }
        }

        #endregion

        #region Public Methods
        /// <summary>
        /// 
        /// </summary>
        /// <param name="textToFormat"></param>
        /// <param name="htmlElement"></param>
        /// <param name="attributeText"></param>
        /// <returns></returns>
        public static string GetElementMarkUp(string textToFormat,string htmlElement,string attributeText)
        {
            string elementMarkUp;
            if (attributeText!=String.Empty)
            {
                elementMarkUp = m_tagLeft + htmlElement + m_space + attributeText + m_tagRight + textToFormat + m_endTagLeft + htmlElement + m_tagRight;
            }
            else
            {
                elementMarkUp = m_tagLeft + htmlElement + m_tagRight + textToFormat + m_endTagLeft + htmlElement + m_tagRight; 
            }
            return elementMarkUp;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="htmlElement"></param>
        /// <param name="attributeText"></param>
        /// <returns></returns>
        public static string GetSelfClosingElementMarkUp(string htmlElement, string attributeText)
        {
            string selfClosingElementMarkUp = string.Empty;
            if (attributeText != String.Empty)
            {
                selfClosingElementMarkUp = m_tagLeft + htmlElement + m_space + attributeText + m_selfClosingTagEnd;
            }
            return selfClosingElementMarkUp;
        }
        #endregion

    }
}
